//
// Created by 紫霄 on 2020/4/29.
//

#ifndef LEETCODE_62_H
#define LEETCODE_62_H
#include <algorithm>
#include <vector>
using namespace std;
class Solution {
public:
  int lastRemaining(int n, int m) {
    int ans = 0;
    for (int i = 2; i < n + 1; ++i) {
      ans = (ans + m) % i;
    }
    return ans;
  }
};
#endif // LEETCODE_62_H
